﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using DrugStore.Models;

namespace DrugStore.Controllers
{
   
    public class DiseaseController : Controller
    {

        //Declare the disease service.
        private DiseaseService service;
        //
        // GET: /Disease/

        public ActionResult Index()
        {
            return View();
        }

        //
        // GET: /Disease/Details/5
        [ValidateInput(false)]
        public ActionResult Details(String id)
        {
            try 
            {
                service = new DiseaseService();
                DiseaseModel disease = service.SelectDisease(id);
                if (disease != null) 
                {
                    return View(disease);
                }
            }
            catch (System.Exception ex) 
            {
                ViewData.Add("Error", ex.Message);
            }
            return View();
        }

        //
        // GET: /Disease/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /Disease/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        
        //
        // GET: /Disease/Edit/5
 
        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /Disease/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Disease/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /Disease/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
